package com.shanxia.im.sdk.server.handler.inner;

import com.shanxia.codec.ProtocolDataBase;
import com.shanxia.codec.cmd.Cmd101;
import com.shanxia.codec.cmd.Cmd102;
import com.shanxia.im.sdk.server.handler.IMRequestHandler;
import com.shanxia.im.sdk.server.model.IMSession;

/**
 * 心跳handler，主要是让netty重置channel的空闲时间
 */
public class HeartbeatHandler implements IMRequestHandler {
	@Override
    public void process(IMSession session, ProtocolDataBase protocolDataBase) {
        System.out.println("......server收到102心跳......");
	    // 102心跳包 TODO 暂时注释，正式调试时需要打开
        if(protocolDataBase instanceof Cmd102){
            Cmd101 cmd101 = new Cmd101();
            cmd101.copyDataFrom(cmd101);
            cmd101.setCmd(101);
            cmd101.setHeart(1);
            session.write(cmd101);
        }
    }
}
